<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    {% load static %}
    <script src="{% static 'jquery-3.7.1.min.js' %}"></script>

</head>
<script>
    $(function () {
        $("#bt01").click(function () {
            var value = $.ajax({
                type: "GET",
                url: "/getHeader",
                dataType: "json",
                async: false,
                headers: {
                    "sign": "123",
                }
            }).responseJSON;
            {# 触发ajax,获取视图函数getheader的数据 #}
            value = '<h2>' + value["header"] + '</h2>';
            $("#myDiv").html(value);
        })
    })


</script>

<body>
<h3>hello headers</h3>
<div id="myDiv"><h2>ajax获取请求头</h2></div>
<button id="bt01" type="button">改变内容</button>
</body>
</html>